3.5.38 \(\int (a+b \tan (c+d x))^3 \, dx\) [438]

Optimal. Leaf size=72 \[ a \left (a^2-3 b^2\right ) x-\frac {b \left (3 a^2-b^2\right ) \log (\cos (c+d x))}{d}+\frac {2 a b^2 \tan (c+d x)}{d}+\frac {b (a+b \tan (c+d x))^2}{2 d} \]

[Out]

a*(a^2-3*b^2)*x-b*(3*a^2-b^2)*ln(cos(d*x+c))/d+2*a*b^2*tan(d*x+c)/d+1/2*b*(a+b*tan(d*x+c))^2/d

________________________________________________________________________________________

Rubi [A]
time = 0.04, antiderivative size = 72, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 3, integrand size = 12, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.250, Rules used = {3563, 3606, 3556} \begin {gather*} -\frac {b \left (3 a^2-b^2\right ) \log (\cos (c+d x))}{d}+a x \left (a^2-3 b^2\right )+\frac {2 a b^2 \tan (c+d x)}{d}+\frac {b (a+b \tan (c+d x))^2}{2 d} \end {gather*}

Antiderivative was successfully verified.

[In]

Int[(a + b*Tan[c + d*x])^3,x]

[Out]

a*(a^2 - 3*b^2)*x - (b*(3*a^2 - b^2)*Log[Cos[c + d*x]])/d + (2*a*b^2*Tan[c + d*x])/d + (b*(a + b*Tan[c + d*x])
^2)/(2*d)

Rule 3556

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rule 3563

Int[((a_) + (b_.)*tan[(c_.) + (d_.)*(x_)])^(n_), x_Symbol] :> Simp[b*((a + b*Tan[c + d*x])^(n - 1)/(d*(n - 1))
), x] + Int[(a^2 - b^2 + 2*a*b*Tan[c + d*x])*(a + b*Tan[c + d*x])^(n - 2), x] /; FreeQ[{a, b, c, d}, x] && NeQ
[a^2 + b^2, 0] && GtQ[n, 1]

Rule 3606

Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(a*c - b
*d)*x, x] + (Dist[b*c + a*d, Int[Tan[e + f*x], x], x] + Simp[b*d*(Tan[e + f*x]/f), x]) /; FreeQ[{a, b, c, d, e
, f}, x] && NeQ[b*c - a*d, 0] && NeQ[b*c + a*d, 0]

Rubi steps

\begin {align*} \int (a+b \tan (c+d x))^3 \, dx &=\frac {b (a+b \tan (c+d x))^2}{2 d}+\int (a+b \tan (c+d x)) \left (a^2-b^2+2 a b \tan (c+d x)\right ) \, dx\\ &=a \left (a^2-3 b^2\right ) x+\frac {2 a b^2 \tan (c+d x)}{d}+\frac {b (a+b \tan (c+d x))^2}{2 d}+\left (b \left (3 a^2-b^2\right )\right ) \int \tan (c+d x) \, dx\\ &=a \left (a^2-3 b^2\right ) x-\frac {b \left (3 a^2-b^2\right ) \log (\cos (c+d x))}{d}+\frac {2 a b^2 \tan (c+d x)}{d}+\frac {b (a+b \tan (c+d x))^2}{2 d}\\ \end {align*}

________________________________________________________________________________________

Mathematica [C] Result contains complex when optimal does not.
time = 0.25, size = 79, normalized size = 1.10 \begin {gather*} \frac {(i a-b)^3 \log (i-\tan (c+d x))-(i a+b)^3 \log (i+\tan (c+d x))+6 a b^2 \tan (c+d x)+b^3 \tan ^2(c+d x)}{2 d} \end {gather*}

Antiderivative was successfully verified.

[In]

Integrate[(a + b*Tan[c + d*x])^3,x]

[Out]

((I*a - b)^3*Log[I - Tan[c + d*x]] - (I*a + b)^3*Log[I + Tan[c + d*x]] + 6*a*b^2*Tan[c + d*x] + b^3*Tan[c + d*
x]^2)/(2*d)

________________________________________________________________________________________

Maple [A]
time = 0.03, size = 74, normalized size = 1.03

method result size
norman \(\left (a^{3}-3 b^{2} a \right ) x +\frac {b^{3} \left (\tan ^{2}\left (d x +c \right )\right )}{2 d}+\frac {3 a \,b^{2} \tan \left (d x +c \right )}{d}+\frac {b \left (3 a^{2}-b^{2}\right ) \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2 d}\) \(73\)
derivativedivides \(\frac {\frac {b^{3} \left (\tan ^{2}\left (d x +c \right )\right )}{2}+3 b^{2} a \tan \left (d x +c \right )+\frac {\left (3 a^{2} b -b^{3}\right ) \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2}+\left (a^{3}-3 b^{2} a \right ) \arctan \left (\tan \left (d x +c \right )\right )}{d}\) \(74\)
default \(\frac {\frac {b^{3} \left (\tan ^{2}\left (d x +c \right )\right )}{2}+3 b^{2} a \tan \left (d x +c \right )+\frac {\left (3 a^{2} b -b^{3}\right ) \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2}+\left (a^{3}-3 b^{2} a \right ) \arctan \left (\tan \left (d x +c \right )\right )}{d}\) \(74\)
risch \(3 i x b \,a^{2}-i b^{3} x +a^{3} x -3 a \,b^{2} x +\frac {6 i b \,a^{2} c}{d}-\frac {2 i b^{3} c}{d}+\frac {2 b^{2} \left (3 i a \,{\mathrm e}^{2 i \left (d x +c \right )}+b \,{\mathrm e}^{2 i \left (d x +c \right )}+3 i a \right )}{d \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )^{2}}-\frac {3 b \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right ) a^{2}}{d}+\frac {b^{3} \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )}{d}\) \(140\)

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((a+b*tan(d*x+c))^3,x,method=_RETURNVERBOSE)

[Out]

1/d*(1/2*b^3*tan(d*x+c)^2+3*b^2*a*tan(d*x+c)+1/2*(3*a^2*b-b^3)*ln(1+tan(d*x+c)^2)+(a^3-3*a*b^2)*arctan(tan(d*x
+c)))

________________________________________________________________________________________

Maxima [A]
time = 0.52, size = 78, normalized size = 1.08 \begin {gather*} a^{3} x - \frac {3 \, {\left (d x + c - \tan \left (d x + c\right )\right )} a b^{2}}{d} - \frac {b^{3} {\left (\frac {1}{\sin \left (d x + c\right )^{2} - 1} - \log \left (\sin \left (d x + c\right )^{2} - 1\right )\right )}}{2 \, d} + \frac {3 \, a^{2} b \log \left (\sec \left (d x + c\right )\right )}{d} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*tan(d*x+c))^3,x, algorithm="maxima")

[Out]

a^3*x - 3*(d*x + c - tan(d*x + c))*a*b^2/d - 1/2*b^3*(1/(sin(d*x + c)^2 - 1) - log(sin(d*x + c)^2 - 1))/d + 3*
a^2*b*log(sec(d*x + c))/d

________________________________________________________________________________________

Fricas [A]
time = 1.66, size = 71, normalized size = 0.99 \begin {gather*} \frac {b^{3} \tan \left (d x + c\right )^{2} + 6 \, a b^{2} \tan \left (d x + c\right ) + 2 \, {\left (a^{3} - 3 \, a b^{2}\right )} d x - {\left (3 \, a^{2} b - b^{3}\right )} \log \left (\frac {1}{\tan \left (d x + c\right )^{2} + 1}\right )}{2 \, d} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*tan(d*x+c))^3,x, algorithm="fricas")

[Out]

1/2*(b^3*tan(d*x + c)^2 + 6*a*b^2*tan(d*x + c) + 2*(a^3 - 3*a*b^2)*d*x - (3*a^2*b - b^3)*log(1/(tan(d*x + c)^2
 + 1)))/d

________________________________________________________________________________________

Sympy [A]
time = 0.09, size = 94, normalized size = 1.31 \begin {gather*} \begin {cases} a^{3} x + \frac {3 a^{2} b \log {\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )}}{2 d} - 3 a b^{2} x + \frac {3 a b^{2} \tan {\left (c + d x \right )}}{d} - \frac {b^{3} \log {\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )}}{2 d} + \frac {b^{3} \tan ^{2}{\left (c + d x \right )}}{2 d} & \text {for}\: d \neq 0 \\x \left (a + b \tan {\left (c \right )}\right )^{3} & \text {otherwise} \end {cases} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*tan(d*x+c))**3,x)

[Out]

Piecewise((a**3*x + 3*a**2*b*log(tan(c + d*x)**2 + 1)/(2*d) - 3*a*b**2*x + 3*a*b**2*tan(c + d*x)/d - b**3*log(
tan(c + d*x)**2 + 1)/(2*d) + b**3*tan(c + d*x)**2/(2*d), Ne(d, 0)), (x*(a + b*tan(c))**3, True))

________________________________________________________________________________________

Giac [B] Leaf count of result is larger than twice the leaf count of optimal. 603 vs. \(2 (70) = 140\).
time = 0.80, size = 603, normalized size = 8.38 \begin {gather*} \frac {2 \, a^{3} d x \tan \left (d x\right )^{2} \tan \left (c\right )^{2} - 6 \, a b^{2} d x \tan \left (d x\right )^{2} \tan \left (c\right )^{2} - 3 \, a^{2} b \log \left (\frac {4 \, {\left (\tan \left (d x\right )^{4} \tan \left (c\right )^{2} - 2 \, \tan \left (d x\right )^{3} \tan \left (c\right ) + \tan \left (d x\right )^{2} \tan \left (c\right )^{2} + \tan \left (d x\right )^{2} - 2 \, \tan \left (d x\right ) \tan \left (c\right ) + 1\right )}}{\tan \left (c\right )^{2} + 1}\right ) \tan \left (d x\right )^{2} \tan \left (c\right )^{2} + b^{3} \log \left (\frac {4 \, {\left (\tan \left (d x\right )^{4} \tan \left (c\right )^{2} - 2 \, \tan \left (d x\right )^{3} \tan \left (c\right ) + \tan \left (d x\right )^{2} \tan \left (c\right )^{2} + \tan \left (d x\right )^{2} - 2 \, \tan \left (d x\right ) \tan \left (c\right ) + 1\right )}}{\tan \left (c\right )^{2} + 1}\right ) \tan \left (d x\right )^{2} \tan \left (c\right )^{2} - 4 \, a^{3} d x \tan \left (d x\right ) \tan \left (c\right ) + 12 \, a b^{2} d x \tan \left (d x\right ) \tan \left (c\right ) + b^{3} \tan \left (d x\right )^{2} \tan \left (c\right )^{2} + 6 \, a^{2} b \log \left (\frac {4 \, {\left (\tan \left (d x\right )^{4} \tan \left (c\right )^{2} - 2 \, \tan \left (d x\right )^{3} \tan \left (c\right ) + \tan \left (d x\right )^{2} \tan \left (c\right )^{2} + \tan \left (d x\right )^{2} - 2 \, \tan \left (d x\right ) \tan \left (c\right ) + 1\right )}}{\tan \left (c\right )^{2} + 1}\right ) \tan \left (d x\right ) \tan \left (c\right ) - 2 \, b^{3} \log \left (\frac {4 \, {\left (\tan \left (d x\right )^{4} \tan \left (c\right )^{2} - 2 \, \tan \left (d x\right )^{3} \tan \left (c\right ) + \tan \left (d x\right )^{2} \tan \left (c\right )^{2} + \tan \left (d x\right )^{2} - 2 \, \tan \left (d x\right ) \tan \left (c\right ) + 1\right )}}{\tan \left (c\right )^{2} + 1}\right ) \tan \left (d x\right ) \tan \left (c\right ) - 6 \, a b^{2} \tan \left (d x\right )^{2} \tan \left (c\right ) - 6 \, a b^{2} \tan \left (d x\right ) \tan \left (c\right )^{2} + 2 \, a^{3} d x - 6 \, a b^{2} d x + b^{3} \tan \left (d x\right )^{2} + b^{3} \tan \left (c\right )^{2} - 3 \, a^{2} b \log \left (\frac {4 \, {\left (\tan \left (d x\right )^{4} \tan \left (c\right )^{2} - 2 \, \tan \left (d x\right )^{3} \tan \left (c\right ) + \tan \left (d x\right )^{2} \tan \left (c\right )^{2} + \tan \left (d x\right )^{2} - 2 \, \tan \left (d x\right ) \tan \left (c\right ) + 1\right )}}{\tan \left (c\right )^{2} + 1}\right ) + b^{3} \log \left (\frac {4 \, {\left (\tan \left (d x\right )^{4} \tan \left (c\right )^{2} - 2 \, \tan \left (d x\right )^{3} \tan \left (c\right ) + \tan \left (d x\right )^{2} \tan \left (c\right )^{2} + \tan \left (d x\right )^{2} - 2 \, \tan \left (d x\right ) \tan \left (c\right ) + 1\right )}}{\tan \left (c\right )^{2} + 1}\right ) + 6 \, a b^{2} \tan \left (d x\right ) + 6 \, a b^{2} \tan \left (c\right ) + b^{3}}{2 \, {\left (d \tan \left (d x\right )^{2} \tan \left (c\right )^{2} - 2 \, d \tan \left (d x\right ) \tan \left (c\right ) + d\right )}} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*tan(d*x+c))^3,x, algorithm="giac")

[Out]

1/2*(2*a^3*d*x*tan(d*x)^2*tan(c)^2 - 6*a*b^2*d*x*tan(d*x)^2*tan(c)^2 - 3*a^2*b*log(4*(tan(d*x)^4*tan(c)^2 - 2*
tan(d*x)^3*tan(c) + tan(d*x)^2*tan(c)^2 + tan(d*x)^2 - 2*tan(d*x)*tan(c) + 1)/(tan(c)^2 + 1))*tan(d*x)^2*tan(c
)^2 + b^3*log(4*(tan(d*x)^4*tan(c)^2 - 2*tan(d*x)^3*tan(c) + tan(d*x)^2*tan(c)^2 + tan(d*x)^2 - 2*tan(d*x)*tan
(c) + 1)/(tan(c)^2 + 1))*tan(d*x)^2*tan(c)^2 - 4*a^3*d*x*tan(d*x)*tan(c) + 12*a*b^2*d*x*tan(d*x)*tan(c) + b^3*
tan(d*x)^2*tan(c)^2 + 6*a^2*b*log(4*(tan(d*x)^4*tan(c)^2 - 2*tan(d*x)^3*tan(c) + tan(d*x)^2*tan(c)^2 + tan(d*x
)^2 - 2*tan(d*x)*tan(c) + 1)/(tan(c)^2 + 1))*tan(d*x)*tan(c) - 2*b^3*log(4*(tan(d*x)^4*tan(c)^2 - 2*tan(d*x)^3
*tan(c) + tan(d*x)^2*tan(c)^2 + tan(d*x)^2 - 2*tan(d*x)*tan(c) + 1)/(tan(c)^2 + 1))*tan(d*x)*tan(c) - 6*a*b^2*
tan(d*x)^2*tan(c) - 6*a*b^2*tan(d*x)*tan(c)^2 + 2*a^3*d*x - 6*a*b^2*d*x + b^3*tan(d*x)^2 + b^3*tan(c)^2 - 3*a^
2*b*log(4*(tan(d*x)^4*tan(c)^2 - 2*tan(d*x)^3*tan(c) + tan(d*x)^2*tan(c)^2 + tan(d*x)^2 - 2*tan(d*x)*tan(c) +
1)/(tan(c)^2 + 1)) + b^3*log(4*(tan(d*x)^4*tan(c)^2 - 2*tan(d*x)^3*tan(c) + tan(d*x)^2*tan(c)^2 + tan(d*x)^2 -
 2*tan(d*x)*tan(c) + 1)/(tan(c)^2 + 1)) + 6*a*b^2*tan(d*x) + 6*a*b^2*tan(c) + b^3)/(d*tan(d*x)^2*tan(c)^2 - 2*
d*tan(d*x)*tan(c) + d)

________________________________________________________________________________________

Mupad [B]
time = 3.82, size = 106, normalized size = 1.47 \begin {gather*} \frac {b^3\,{\mathrm {tan}\left (c+d\,x\right )}^2}{2\,d}+\frac {\ln \left ({\mathrm {tan}\left (c+d\,x\right )}^2+1\right )\,\left (\frac {3\,a^2\,b}{2}-\frac {b^3}{2}\right )}{d}+\frac {3\,a\,b^2\,\mathrm {tan}\left (c+d\,x\right )}{d}-\frac {a\,\mathrm {atan}\left (\frac {a\,\mathrm {tan}\left (c+d\,x\right )\,\left (a^2-3\,b^2\right )}{3\,a\,b^2-a^3}\right )\,\left (a^2-3\,b^2\right )}{d} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((a + b*tan(c + d*x))^3,x)

[Out]

(b^3*tan(c + d*x)^2)/(2*d) + (log(tan(c + d*x)^2 + 1)*((3*a^2*b)/2 - b^3/2))/d + (3*a*b^2*tan(c + d*x))/d - (a
*atan((a*tan(c + d*x)*(a^2 - 3*b^2))/(3*a*b^2 - a^3))*(a^2 - 3*b^2))/d

________________________________________________________________________________________